#include <iostream>
#include <string>

using namespace std;

int main(){
	string a;
	string c;
	cin >> a;
	cin >> c;
	
	for(int i = 0; i < a.length(); i++){
		char x = '0';
		int j = 0; 
		for(int k = 0; k < c.length(); k++){
			if(c[k] > x){
				x = c[k];
				j = k;
			}
		} 
		if(x>a[i]){
			a[i] = x;
			for(int k = j; k < c.length(); k++){
				c[k] = c[k+1];
			}
		}
	}
	cout << a;
}
